<template>
  <div>
    <!-- 搜索栏区域 -->
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="学号">
        <el-input v-model="formInline.user" placeholder="学号"></el-input>
      </el-form-item>
      <el-form-item label="学院">
        <el-select v-model="formInline.region" placeholder="学院">
          <el-option
            v-for="(item, index) in collegeName"
            :key="index"
            :value="item.college"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>

    <!-- 表格显示区域 -->
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="姓名" width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.student_name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="毕业设计题目" width="280">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.topic_name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="毕业答辩状态" width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.status }}</span>
        </template>
      </el-table-column>
      <el-table-column label="论文类型" width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.article_type }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最终成绩" width="180">
        <template slot-scope="scope">
          <a href="javascript:;" @click="show(scope.row)">
            {{ scope.row.allScore }}
          </a>
        </template>
      </el-table-column>
      <el-table-column label="终稿">
        <template slot-scope="scope">
          <a href="javascript:;" @click="handleEdit(scope.row)">{{
            scope.row.article_name
          }}</a>
        </template>
      </el-table-column>
    </el-table>

    <!-- 成绩弹出框 -->
    <el-dialog title="提示" :visible.sync="dialogVisibles" width="40%">
      <el-descriptions class="margin-top" :column="2" border>
        <el-descriptions-item width="40px">
          <template slot="label">指导教师评分</template>
          {{ score.article_teacherscore }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">指导教师评语</template>
          {{ score.teacher_observation }}
        </el-descriptions-item>
        <el-descriptions-item width="40px">
          <template slot="label">评阅教师评分</template>
          {{ score.look_teacherScore }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">评阅教师评语</template>
          {{ score.look_teacherObservation }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label" width="40px">答辩教师评分</template>
          {{ score.reply_score }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">答辩教师评语</template>
          {{ score.reply_observation }}
        </el-descriptions-item>
      </el-descriptions>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibles = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisibles = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!-- 分页区域 -->
    <el-pagination
      background
      @current-change="currentChange"
      @prev-click="prevClick"
      @next-click="nextClick"
      layout="prev, pager, next"
      :page-size="quertinfo.pageSize"
      :total="total"
      :hide-on-single-page="true"
    >
    </el-pagination>
  </div>
</template>
<script>
import { mapState } from "vuex";
export default {
  created() {
    this.get_allPaper();
  },
  data() {
    return {
      total: null,
      quertinfo: {
        current: 1,
        pageSize: 5,
      },
      dialogVisible: false,
      dialogVisibles: false,
      tableData: [],
      score: {},
      formInline: {},
    };
  },
  computed: {
    ...mapState(["collegeName"]),
  },
  methods: {
    onSubmit() {
      this.get_allPaper();
    },

    handleEdit(row) {
      // console.log(row);
      location.href = "http://127.0.0.1:8080/api/download_paper?id=" + row.id;
    },
    // 获取学生的毕业设计情况
    get_allPaper() {
      const info = { ...this.formInline, ...this.quertinfo };
      this.$http
        .get("http://127.0.0.1:8080/bigAdmin/get_allPaper", { params: info })
        .then((res) => {
          // console.log(res);
          if (res.data.status == 0) {
            // console.log(res.data.data);
            this.tableData = res.data.data.datalist;
            this.total = res.data.data.total;
          } else {
            this.tableData = [];
            // this.$message.error(res.data.message);
          }
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    show(row) {
      this.dialogVisibles = true;
      this.score = row;
      // console.log(row);
    },

    currentChange(val) {
      this.quertinfo.current = val;
      this.get_allPaper();
    },
    prevClick(val) {
      this.quertinfo.current = val;
      this.get_allPaper();
    },
    nextClick(val) {
      this.quertinfo.current = val;
      this.get_allPaper();
    },
  },
};
</script>
<style lang="less" scoped>
.el-pagination {
  position: fixed;
  left: 50%;
  top: 80%;
}
</style>
